set(CMAKE_SYSTEM_NAME Emscripten)
set(CMAKE_SYSTEM_VERSION 1)

set(WIN32)
set(APPLE)
set(UNIX 1)

set(CMAKE_C_COMPILER ${EMCC_EXECUTABLE})
set(CMAKE_CXX_COMPILER ${EMXX_EXECUTABLE})
set(CMAKE_C_COMPILER_AR ${EMAR_EXECUTABLE})
set(CMAKE_CXX_COMPILER_AR ${EMAR_EXECUTABLE})
set(CMAKE_C_COMPILER_RANLIB ${EMRANLIB_EXECUTABLE})
set(CMAKE_CXX_COMPILER_RANLIB ${EMRANLIB_EXECUTABLE})
set(CMAKE_CROSSCOMPILING_EMULATOR ${NODE_JS_EXECUTABLE})

set(CMAKE_C_STANDARD_LIBRARIES "")
set(CMAKE_CXX_STANDARD_LIBRARIES "")
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "")
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "${EMSCRIPTEN_SYSROOT}/include")
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "${EMSCRIPTEN_SYSROOT}/include")

list(FIND CMAKE_C_COMPILER_PREDEFINES_COMMAND -m64 found)
if(${found} GREATER 0)
  unset(CMAKE_C_COMPILER_ARG${found} CACHE)
  unset(CMAKE_C_COMPILER_ARG${found})
endif()
list(FIND CMAKE_CXX_COMPILER_PREDEFINES_COMMAND -m64 found)
if(${found} GREATER 0)
  unset(CMAKE_CXX_COMPILER_ARG${found} CACHE)
  unset(CMAKE_CXX_COMPILER_ARG${found})
endif()
